﻿using Furion.DynamicApiController;
using HOPU.OnlineSchool.Application.Teachers.Dto;
using HOPU.OnlineSchool.Application.Teachers.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HOPU.OnlineSchool.Application.Teachers
{
    /// <summary>
    /// 教师列表接口
    /// </summary>
    public class TeacherAppServices : IDynamicApiController
    {
        private readonly ITeacherServices _teacherServices;

        public TeacherAppServices(ITeacherServices teacherServices)
        {
            _teacherServices = teacherServices;
        }

        /// <summary>
        /// 分页查询教师列表信息
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<PagedList<TeacherListOutput>> PostTeacherList(int page, int limit, TeacherListInput input)
        {
            return await _teacherServices.PagedListAsync(page, limit, input);
        }

        /// <summary>
        /// 添加讲师
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task PostAdd(TeacherAddInput input)
        {
            await _teacherServices.AddAsync(input);
        }

        /// <summary>
        /// 删除讲师
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task Delete(string id)
        {
            await _teacherServices.DeleteAsync(id);
        }

        /// <summary>
        /// 根据id查询教师信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<TeacherAddInput> Get(string id)
        {
            return await _teacherServices.GetTeacherById(id);
        }

        /// <summary>
        /// 根据id修改对应的教师信息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task Update(string id, TeacherAddInput dto)
        {
            await _teacherServices.UpdateTeacherById(id, dto);
        }
    }
}
